package ru.ifmo.thesis.solver.gp;

import org.jgap.Genotype;

public class FixedIterations implements CompletionRule {

	private static final int DEFAULT_ITERATIONS = 1000;
	
	private final int maxIterations;

	private int iterationCount = 0;
	
	public FixedIterations() {
		this(DEFAULT_ITERATIONS);
	}
	
	public FixedIterations(int iterationCount) {
		this.maxIterations = iterationCount;
	}

	@Override
	public boolean isTaskCompleted(Genotype population) {
		return iterationCount++ >= maxIterations;
	}

	@Override
	public CompletionRule newCopy() {
		return new FixedIterations(maxIterations);
	}

}
